package com.kun.util;

import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 静态内部类只有在使用的时候才会加载,
 * 因此可以实现懒加载的效果,同时类初始化的线程安全性,
 * 保证了实例的唯一性
 * @author kun.li
 */
public class PasswordUtil {


    private static class PasswordHolder {
        private static final PasswordEncoder INSTANCE = PasswordEncoderFactories.createDelegatingPasswordEncoder();
    }

    public static PasswordEncoder getInstance() {
        return PasswordHolder.INSTANCE;
    }


}
